package com.ljx.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 购物车
 * @TableName o_cart
 */
@TableName(value ="o_cart")
@Data
@ApiModel("购物车信息表")
public class Cart implements Serializable {
    /**
     * 
     */
    @TableId
    @ApiModelProperty(name = "id",value = "购物车", dataType = "String")
    private String id;

    /**
     * 用户id
     */
    @ApiModelProperty(name = "uid",value = "用户id", dataType = "String")
    private String uid;

    /**
     * 商品id
     */
    @ApiModelProperty(name = "goodsId",value = "商品id", dataType = "String")
    private String goodsId;

    /**
     * 商品数量
     */
    @ApiModelProperty(name = "num",value = "商品数量", dataType = "Integer")
    private Integer num;

    /**
     * 商品价格
     */
    @ApiModelProperty(name = "price",value = "商品价格", dataType = "BigDecimal")
    private BigDecimal price;

    /**
     * 收货地址
     */
    @ApiModelProperty(name = "addrid",value = "收货地址", dataType = "String")
    private String addrid;

    /**
     * 逻辑删除
     */
    @TableLogic
    @ApiModelProperty(name = "isDeleted",value = "逻辑删除", dataType = "Integer")
    private Integer isDeleted;

    @TableField(exist = false)
    @ApiModelProperty(name = "goods",value = "购物车中商品详情", dataType = "Goods")
    private Goods goods;

//    @TableField(exist = false)
//    @ApiModelProperty(name = "stock",value = "商品库存", dataType = "Stock")
//    private Stock stock;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Cart other = (Cart) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUid() == null ? other.getUid() == null : this.getUid().equals(other.getUid()))
            && (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
            && (this.getNum() == null ? other.getNum() == null : this.getNum().equals(other.getNum()))
            && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
            && (this.getAddrid() == null ? other.getAddrid() == null : this.getAddrid().equals(other.getAddrid()))
            && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUid() == null) ? 0 : getUid().hashCode());
        result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
        result = prime * result + ((getNum() == null) ? 0 : getNum().hashCode());
        result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
        result = prime * result + ((getAddrid() == null) ? 0 : getAddrid().hashCode());
        result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", uid=").append(uid);
        sb.append(", goodsId=").append(goodsId);
        sb.append(", num=").append(num);
        sb.append(", price=").append(price);
        sb.append(", addrid=").append(addrid);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}